package moodish.server;

import java.io.Serializable;

/**
 * @author JoseLourenco
 *
 *O objectivo desta classe e representar os dados de um utilizador
 *(nickname e mood)
 */
public class User implements Serializable{
	
	private static final long serialVersionUID = 1L;
	private static final String SEPARATOR = ":";
	
	private String nickname;
	private String mood;
	
	
	/**
	 * Constructor da classe
	 * @param nickname
	 */
	public User(String nickname) {
		this.nickname = nickname;
	}


	/**
	 * @return mood
	 */
	public String getMood() {
		return mood;
	}


	/**
	 * @param mood
	 */
	public void setMood(String mood) {
		this.mood = mood;
	}


	/**
	 * @return nickname
	 */
	public String getNickname() {
		return nickname;
	}
	
	
	/**
	 * Redefinicao do metodo equals de modo a dizer que dois 
	 * Users sao iguais se tiverem o mesmo nickname
	 */
	@Override
	public boolean equals(Object object){
		
		if(object instanceof User){
			User otherUser = (User) object;
			
			if(this.nickname.equals(otherUser.getNickname())){
				return true;
			}
		}
		return false;
	}

	
	/**
	 * toString devolvendo o nickname e mood do User
	 */
	@Override
	public String toString(){
		return nickname + SEPARATOR + mood;
	}
}
